<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>db_schema — Database Schema Management Module &mdash; Documentation</title>
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Documentation" href="index.html" />
    <link rel="up" title="Server Side Internals" href="server_side_internals.html" />
    <link rel="next" title="db — Database" href="db.html" />
    <link rel="prev" title="code — Code Execution Module" href="code.html" /> 
  </head>
  <body>
    <div style="background-color: #FFF; text-align: left; padding: 8px 0px"><img src="_static/banner300910.gif"></div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="db.html" title="db — Database"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="code.html" title="code — Code Execution Module"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Documentation</a> &raquo;</li>
          <li><a href="server_side_api.html" >3. Server Side API</a> &raquo;</li>
          <li><a href="server_side_internals.html" accesskey="U">Server Side Internals</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href=""><tt class="docutils literal"><span class="pre">db_schema</span></tt> &#8212; Database Schema Management Module</a><ul>
<li><a class="reference external" href="#standard-fields-of-a-record">Standard fields of a record</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="code.html"
                                  title="previous chapter"><tt class="docutils literal docutils literal"><span class="pre">code</span></tt> &#8212; Code Execution Module</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="db.html"
                                  title="next chapter"><tt class="docutils literal docutils literal"><span class="pre">db</span></tt> &#8212; Database</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/db_schema.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-db_schema">
<h1><tt class="xref docutils literal"><span class="pre">db_schema</span></tt> &#8212; Database Schema Management Module<a class="headerlink" href="#module-db_schema" title="Permalink to this headline">¶</a></h1>
<p>Syncs a database table to the <cite>DocType</cite> (metadata)
<em>Note</em> This module is only used internally</p>
<dl class="method">
<dt id="db_schema.updatedb">
<tt class="descclassname">db_schema.</tt><tt class="descname">updatedb</tt><big>(</big><em>dt</em><big>)</big><a class="headerlink" href="#db_schema.updatedb" title="Permalink to this definition">¶</a></dt>
<dd>Syncs a <cite>DocType</cite> to the table
* creates if required
* updates columns
* updates indices</dd></dl>

<dl class="method">
<dt id="db_schema.getcoldef">
<tt class="descclassname">db_schema.</tt><tt class="descname">getcoldef</tt><big>(</big><em>ftype</em>, <em>length=''</em><big>)</big><a class="headerlink" href="#db_schema.getcoldef" title="Permalink to this definition">¶</a></dt>
<dd><p>converts the user defined field types (ftype) to database fieldtypes
example: <cite>Data</cite> becomes <cite>varchar(180)</cite></p>
<p>Default field lengths:</p>
<ul class="simple">
<li>180  - Data / Select / Link / Read Only / Password</li>
<li>14,2 - Currency</li>
<li>14,6 - Float</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="db_schema.updatecolumns">
<tt class="descclassname">db_schema.</tt><tt class="descname">updatecolumns</tt><big>(</big><em>doctype</em><big>)</big><a class="headerlink" href="#db_schema.updatecolumns" title="Permalink to this definition">¶</a></dt>
<dd><p>Updates columns from the <cite>DocType</cite> to the table</p>
<ul class="simple">
<li>adds a column if new</li>
<li>changes the name if oldfieldname != fieldname</li>
<li>changes the type</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="db_schema.updateindex">
<tt class="descclassname">db_schema.</tt><tt class="descname">updateindex</tt><big>(</big><em>doctype</em><big>)</big><a class="headerlink" href="#db_schema.updateindex" title="Permalink to this definition">¶</a></dt>
<dd>Adds / removes indices from the given doctype table</dd></dl>

<dl class="method">
<dt id="db_schema.update_engine">
<tt class="descclassname">db_schema.</tt><tt class="descname">update_engine</tt><big>(</big><em>doctype=None</em>, <em>engine='InnoDB'</em><big>)</big><a class="headerlink" href="#db_schema.update_engine" title="Permalink to this definition">¶</a></dt>
<dd>Not used: Updated the MySQL table engine</dd></dl>

<dl class="method">
<dt id="db_schema.create_table">
<tt class="descclassname">db_schema.</tt><tt class="descname">create_table</tt><big>(</big><em>dt</em><big>)</big><a class="headerlink" href="#db_schema.create_table" title="Permalink to this definition">¶</a></dt>
<dd>Creates a table for a new doctype</dd></dl>

<div class="section" id="standard-fields-of-a-record">
<h2>Standard fields of a record<a class="headerlink" href="#standard-fields-of-a-record" title="Permalink to this headline">¶</a></h2>
<blockquote>
<ul class="simple">
<li><cite>name</cite>: ID / primary key</li>
<li><cite>owner</cite>: creator of the record</li>
<li><cite>creation</cite>: datetime of creation</li>
<li><cite>modified</cite>: datetime of last modification</li>
<li><cite>modified_by</cite> : last updating user</li>
<li><cite>docstatus</cite> : Status 0 - Saved, 1 - Submitted, 2- Cancelled</li>
<li><cite>parent</cite> : if child (table) record, this represents the parent record</li>
<li><cite>parenttype</cite> : type of parent record (if any)</li>
<li><cite>parentfield</cite> : table fieldname of parent record (if any)</li>
<li><cite>idx</cite> : Index (sequence) of the child record</li>
</ul>
</blockquote>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="db.html" title="db — Database"
             >next</a> |</li>
        <li class="right" >
          <a href="code.html" title="code — Code Execution Module"
             >previous</a> |</li>
        <li><a href="index.html">Documentation</a> &raquo;</li>
          <li><a href="server_side_api.html" >3. Server Side API</a> &raquo;</li>
          <li><a href="server_side_internals.html" >Server Side Internals</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Rushabh Mehta.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>